package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TourismRestaurant;
import com.ruoyi.system.service.ITourismRestaurantService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 餐厅Controller
 *
 * @author gqd
 * @date 2020-12-25
 */
@RestController
@RequestMapping("/system/restaurant")
public class TourismRestaurantController extends BaseController
{
    @Autowired
    private ITourismRestaurantService tourismRestaurantService;

    /**
     * 查询餐厅列表
     */
    @PreAuthorize("@ss.hasPermi('system:restaurant:list')")
    @GetMapping("/list")
    public TableDataInfo list(TourismRestaurant tourismRestaurant)
    {
        startPage();
        List<TourismRestaurant> list = tourismRestaurantService.selectTourismRestaurantList(tourismRestaurant);
        return getDataTable(list);
    }

    /**
     * 导出餐厅列表
     */
    @PreAuthorize("@ss.hasPermi('system:restaurant:export')")
    @Log(title = "餐厅", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TourismRestaurant tourismRestaurant)
    {
        List<TourismRestaurant> list = tourismRestaurantService.selectTourismRestaurantList(tourismRestaurant);
        ExcelUtil<TourismRestaurant> util = new ExcelUtil<TourismRestaurant>(TourismRestaurant.class);
        return util.exportExcel(list, "restaurant");
    }

    /**
     * 获取餐厅详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:restaurant:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tourismRestaurantService.selectTourismRestaurantById(id));
    }

    /**
     * 新增餐厅
     */
    @PreAuthorize("@ss.hasPermi('system:restaurant:add')")
    @Log(title = "餐厅", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TourismRestaurant tourismRestaurant)
    {
        return toAjax(tourismRestaurantService.insertTourismRestaurant(tourismRestaurant));
    }

    /**
     * 修改餐厅
     */
    @PreAuthorize("@ss.hasPermi('system:restaurant:edit')")
    @Log(title = "餐厅", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TourismRestaurant tourismRestaurant)
    {
        return toAjax(tourismRestaurantService.updateTourismRestaurant(tourismRestaurant));
    }

    /**
     * 删除餐厅
     */
    @PreAuthorize("@ss.hasPermi('system:restaurant:remove')")
    @Log(title = "餐厅", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tourismRestaurantService.deleteTourismRestaurantByIds(ids));
    }
}
